@include('public.page_styles')
<link rel="stylesheet" type="text/css" href="{{ asset ("/css/timePicker.css") }} ">
<style>
  .time-picker{
    width: 23%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
  }

  .modal{
    background: #f9fafc;
  }
  .modal-footer {
    border-top-color: #9a9393;
  }
</style>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
@include('public.top')
  <!-- Left side column. contains the logo and sidebar -->
@include('public.sidebar')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        {{ trans('message.bankShop') }}
        <small> {{ trans('message.edit') }}</small>
      </h1>
      <ol class="breadcrumb">
        <li><a ><i class="fa fa-dashboard"></i> {{ trans('message.home') }}</a></li>
        <li><a href="{{ url('bankShop/list') }}"> {{ trans('message.bankShopManage') }}</a></li>
        <li class="active"> {{ trans('message.bankShop') }}{{ trans('message.edit') }}</li>
      </ol>
    </section>
    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"> {{ trans('message.edit') }}</h3>
              <div class="box-tools">
                <div class="btn-group pull-right" style="margin-right: 10px">
                  <a href="{{ url('bankShop/list') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp; {{ trans('message.list') }}</a>
                </div>
                <div class="btn-group pull-right" style="margin-right: 10px">
                  <a class="btn btn-sm btn-default form-history-back" onclick="goBack()"><i class="fa fa-arrow-left"></i>&nbsp; {{ trans('message.history-back') }}</a>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form name="editForm"  action="{{ url('bankShop/'.$bankShopInfo->id) }}" method="post"  class="form-horizontal">
              {{--{{ csrf_field() }}--}}
              <input type="hidden" name="_token"   value="{{ csrf_token() }}"/>

              <input type="hidden" name="id"   value="{{ $bankShopInfo->id }}"/>

              <div class="box-body">
                <div class="form-group {!! !$errors->has('shopName') ?: 'has-error' !!}">
                  <label for="shopName" class="col-sm-2 control-label">门店名称</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="text" class="form-control" id="shopName" name="shopName" placeholder="门店名称" value="{{ $bankShopInfo->shopName}}" autofocus required >
                    @if($errors->has('shopName'))
                      @foreach($errors->get('shopName') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group {!! !$errors->has('code') ?: 'has-error' !!}">
                  <label for="code" class="col-sm-2 control-label">网点编号</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" id="code" name="code" placeholder="编号" value="{{ $bankShopInfo->code }}"   >
                    @if($errors->has('code'))
                      @foreach($errors->get('code') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group">
                  <label for="longitude" class="col-sm-2 control-label"></label>
                  <div class="col-sm-8">
                    <a  id="icon_select" class="btn btn-info" style="vertical-align:top">点击获取经纬度</a>
                  </div>
                </div>

                <div class="form-group {!! !$errors->has('longitude') ?: 'has-error' !!}">
                  <label for="longitude" class="col-sm-2 control-label">经度</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="text" id="latitude" class="form-control" name="longitude"   placeholder="经度" value="{{ $bankShopInfo->longitude }}"  autofocus="true" required readonly>
                    @if($errors->has('longitude'))
                      @foreach($errors->get('longitude') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>


                <div class="form-group {!! !$errors->has('latitude') ?: 'has-error' !!}">
                  <label for="latitude" class="col-sm-2 control-label">纬度</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="text" name="latitude"  class="form-control" id="longitude"  placeholder="纬度" value="{{ $bankShopInfo->latitude }}"  autofocus="true" required readonly>
                    @if($errors->has('latitude'))
                      @foreach($errors->get('latitude') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div class="form-group {!! !$errors->has('address') ?: 'has-error' !!}">
                  <label for="address" class="col-sm-2 control-label">门店地址</label>
                  <div class="col-sm-8">
                    <span class="form-control-require">*</span>
                    <input type="text" class="form-control" id="address" name="address" placeholder="输入详细地址" value="{{ $bankShopInfo->address }}"  autofocus required readonly>
                    @if($errors->has('address'))
                      @foreach($errors->get('address') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>
                <div class="form-group {!! !$errors->has('contact') ?: 'has-error' !!}">
                  <label for="contact" class="col-sm-2 control-label">联系人</label>
                  <div class="col-sm-8">
                      <span class="form-control-require">*</span>
                    <input type="text" class="form-control" id="contact" name="contact" placeholder="联系人" value="{{ $bankShopInfo->contact }}"  >
                    @if($errors->has('contact'))
                      @foreach($errors->get('contact') as $message)
                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
                      @endforeach
                    @endif
                  </div>
                </div>

                <div id="phoneDiv" class="form-group {!! !$errors->has('phone') ?: 'has-error' !!}">
                  <label for="phone" class="col-sm-2 control-label">手机号</label>
                  <div class="col-sm-8">
                      <span class="form-control-require">*</span>
                    <input type="text" class="form-control" id="phone" name="phone" placeholder="手机号" value="{{ $bankShopInfo->phone }}"  maxlength="11" >
                      @if($errors->has('phone'))
                          @foreach($errors->get('phone') as $message)
                              <label class="control-label phoneInputError" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label>
                          @endforeach
                      @else
                          <label class="control-label phoneInputError" style="display: none" for="inputError"></label>
                      @endif
                  </div>
                </div>

                  <div id="contact_email" class="form-group {!! !$errors->has('contact_email') ?: 'has-error' !!}">
                      <label for="contact_email" class="col-sm-2 control-label">联系邮箱</label>
                      <div class="col-sm-8">
                          <input type="text" class="form-control" id="contact_email" name="contact_email" placeholder="联系邮箱" value="{{  $bankShopInfo->contact_email }}"  >
                          @if($errors->has('contact_email'))
                              @foreach($errors->get('contact_email') as $message)
                                  <label class="control-label " for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label>
                              @endforeach
                          @endif
                      </div>
                  </div>

                <div class="form-group ">
                  <label for="busStartTime" class="col-sm-2 control-label">营业时间</label>
                  <div class="col-sm-8">
                    <input type="text" class="time-picker" name="busStartTime" value="{{ $bankShopInfo->busStartTime }}" placeholder="开始时间">
                    <input type="text" class="time-picker" name="BusEndTime" value="{{ $bankShopInfo->BusEndTime }}" placeholder="结束时间"><br/>
                  </div>
                </div>

              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <div class="col-sm-2">
                </div>
                <div class="col-sm-8">
                  <div class="btn-group pull-right">
                    <button type="button" class="btn btn-info pull-right btn-js-form-submit" >提交</button>
                  </div>
                  <div class="btn-group pull-left">
                    <button type="reset" class="btn btn-warning">撤销</button>
                  </div>
                </div>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
        </div>
        <!--/.col (right) -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!--modal start-->
  <div class="modal  fade" id="myModal" style="width: 58%;top:20%;left:20%;height: 63%;">
    <div class="modal-body" >
      <div id="iframe-wrap">
        <iframe id="iframe" name="iframe" src="{{ asset('map.html') }}" frameborder="0" width="100%" height="500px">
        </iframe>
      </div>
    </div>
    <div class="modal-footer">
      <a href="#" class="btn btn-default" data-dismiss="modal">关闭</a>
    </div>
  </div>
  <!--modal end-->

@include('public.bottom')

  <!-- Control Sidebar -->
{{--@include('public.aside')--}}
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

@include('public.javascript')
{{--<script src="{{ asset ("/AdminLTE/bower_components/fastclick/lib/fastclick.js") }}" type="text/javascript"></script>--}}
<script type="text/javascript" src="{{ asset ("/js/jquery-timepicker.js") }} "></script>
<script src="{{ asset ("/AdminLTE/bower_components/bootstrap/js/modal.js") }}" type="text/javascript"></script>

<script type="text/javascript">

    $(function(){
        $(".time-picker").hunterTimePicker();

        $('#icon_select').click(function(){
            $('#myModal').modal('show');
        });

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': '{{ csrf_token() }}'
            }
        });


      @if(session()->has('fail'))
           alertMess("{{session()->get('fail')}}");
      @endif
  });

    var _ajaxSubmitSending = false;

    $('#phone').on('input',function(){
        _ajaxSubmitSending = false;
        $(".phoneInputError").hide();
        $('#phoneDiv').removeClass('has-error');

        var phone = $('input[name="phone"]').val();
//        var tel = /^(\d{3,4}-?)?\d{7,9}$/g;
        if(!phone){
            var error = '<i class="fa fa-times-circle-o"></i>手机号不能为空';
            $(".phoneInputError").html(error);
            $(".phoneInputError").show();
            $('#phoneDiv').addClass('has-error');
            _ajaxSubmitSending = true;
            return;
        }
        if(phone){
            var regStr = /^1[0-9]{10}$/;
            if (!regStr.test(phone)) {
                var error = '<p>手机号格式错误</p>';
                $(".phoneInputError").html(error);
                $(".phoneInputError").show();
                $('#phoneDiv').addClass('has-error');
                _ajaxSubmitSending = true;
                return;
            }
        }
    })

    $(".btn-js-form-submit").click(function (e) {
        if (_ajaxSubmitSending) {
            return;
        } else {
            _ajaxSubmitSending = true;
            _loadingFuc();
        }

        $('form[name="editForm"]').submit();
        _ajaxSubmitSending = false;
        setTimeout(function(){
            $.unblockUI();
        }, 1500);
    });


</script>



</body>
</html>
